package org.sky.platform.controller;

import org.sky.platform.model.UserModel;
import org.sky.platform.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@Api(value = "用户测试", tags = {"用户接口"})
@RestController
@RequestMapping("boot")
public class UserController {
	//定义一个全局的记录器，通过LoggerFactory获取
    private final static Logger logger = LoggerFactory.getLogger(UserController.class);

	@Autowired
	private UserService userService;
	/**
	 * 测试单条记录
	 */
	@ApiOperation("获取单个用户信息")
	@ApiImplicitParam(name = "name", value = "用户名", dataType = "string", paramType = "query")
	@RequestMapping(method = RequestMethod.GET, value = "/testDBSelectOne/{name}")
	@ResponseBody
	public UserModel testDBSelectOne(@PathVariable String name) {
		logger.info(">>>>测试日志/boot/testDBSelectOne");
	    UserModel userModel = userService.testDBSelectOne();
	    logger.info(">>>>>>" + JSON.toJSONString(userModel));
	    return userModel;
	}
	@ApiOperation("获取分页用户信息")
	@RequestMapping(method = RequestMethod.GET, value = "/testDBSelectAll")
	@ResponseBody
	public PageInfo<UserModel> testDBSelectAll() {
		logger.info(">>>>测试日志/boot/testDBSelectAll");
	    return userService.testDBSelectAll();
	}
}
